package com.xiaodu.acer.phoneplay.ui.activity;

import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.ionicons_typeface_library.Ionicons;
import com.xiaodu.acer.phoneplay.R;
import com.xiaodu.acer.phoneplay.bean.CategoryBean;
import com.xiaodu.acer.phoneplay.common.Constant;
import com.xiaodu.acer.phoneplay.di.component.AppComponent;
import com.xiaodu.acer.phoneplay.ui.adapter.CategoryAppViewPagerAdapter;
import com.xiaodu.acer.phoneplay.ui.base.BaseActivity;

import butterknife.BindView;

public class CategoryAppActivity extends BaseActivity {

    @BindView(R.id.tab_layout)
    TabLayout mTabLayout;
    @BindView(R.id.tool_bar)
    Toolbar category_toolbar;
    @BindView(R.id.view_pager)
    ViewPager mViewPager;
    private CategoryBean mCategoryBean;

    @Override
    public int setLayout() {
        return R.layout.activity_category_app;
    }

    @Override
    public void setupAcitivtyComponent(AppComponent appComponent) {

    }

    @Override
    public void initView() {
        Intent intent = getIntent();
        mCategoryBean = (CategoryBean) intent.getSerializableExtra(Constant.CATEGORY);
        mToolBar.setVisibility(View.GONE);
        category_toolbar.setTitle(mCategoryBean.getName());

        category_toolbar.setNavigationIcon(
                new IconicsDrawable(this)
                        .icon(Ionicons.Icon.ion_ios_arrow_back)
                        .sizeDp(16)
                        .color(getResources().getColor(R.color.md_white_1000)
                        )
        );


        CategoryAppViewPagerAdapter adapter = new CategoryAppViewPagerAdapter(getSupportFragmentManager(), mCategoryBean.getId());
        mViewPager.setOffscreenPageLimit(adapter.getCount());
        mViewPager.setAdapter(adapter);

        mTabLayout.setupWithViewPager(mViewPager);

    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {
        category_toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }

}
